<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/20
 * Time: 10:19
 */
namespace app\member\controller;
use think\Db;
use think\Session;
use think\Config;
use think\Request;
use think\Loader;
use app\common\controller\simple_html_dom;
use app\member\model\Balance as BalanceModel;
use app\member\model\Changedoc as ChangedocModel;
class Changedoc extends Common
{
	public function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub
		parent::checktype();
    }
    /**
     * 订单列表
     */
    public function index()
    {
        $UrlParam=input();
        $where=array();
        if(!empty($UrlParam['order'])) $where['A.ordernum'] = ['like','%'.$UrlParam['order'].'%'];
        if(!empty($UrlParam['title'])) $where['A.articletitle'] = ['like','%'.$UrlParam['title'].'%'];
        if(isset($UrlParam['status']) && $UrlParam['status']>='0'){			
			$where['A.state'] = $UrlParam['status'];
		}else{
			$UrlParam['status']=-1;
		}
        $where['A.memberid']=$this->MemberID;
        $List =  Db::name('changedoc')
            ->alias('A')
            ->field('A.*,W.article_id,W.media_name,W.fabu_site,W.fabu_content')            
			->join('agencyorder W', 'W.agencyorder_id=A.orderid', 'left')
            ->where($where)
            ->order('A.addtime desc')
            ->paginate(20,true,['query'  => $UrlParam]);
		//echo Db::name('agencyorder')->getLastsql();
		//die;
        $this->assign('UrlParam',$UrlParam);
        $this->assign('list',$List);
        return view();
    }
}